package org.deadline.service.config;

import java.util.List;
import org.deadline.model.config.Enumeration;
import org.deadline.repository.config.EnumerationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class EnumerationServiceImpl implements EnumerationService {

	@Autowired
    EnumerationRepository enumerationRepository;

	public long countAllEnumerations() {
        return enumerationRepository.count();
    }

	public void deleteEnumeration(Enumeration enumeration) {
        enumerationRepository.delete(enumeration);
    }

	public Enumeration findEnumeration(Long id) {
        return enumerationRepository.findOne(id);
    }

	public List<Enumeration> findAllEnumerations() {
        return enumerationRepository.findAll();
    }

	public List<Enumeration> findEnumerationEntries(int firstResult, int maxResults) {
        return enumerationRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveEnumeration(Enumeration enumeration) {
        enumerationRepository.save(enumeration);
    }

	public Enumeration updateEnumeration(Enumeration enumeration) {
        return enumerationRepository.save(enumeration);
    }
}
